From: Ori Livneh Date: Thu, 24 Mar 2016 22:50:44 +0000 (-0700) Subject: Request-local caching of image_redirect X-Git-Tag: 1.31.0-rc.0~7499^2 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=d1c4eafef54f638ef025816b17502250a5be9e73;p=lhc%2Fweb%2Fwiklou.git Request-local caching of image_redirect LocalRepo::checkRedirect() cache image redirect checks in memory to avoid unnecessary trips to memcached. Same idea as Idbd11637. Change-Id: Idaa12376382aaa0bd8cb988240ec1da0b688359d --- diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php index d24aa24cba..d038d937c4 100644 --- a/includes/filerepo/LocalRepo.php +++ b/includes/filerepo/LocalRepo.php @@ -226,7 +226,8 @@ class LocalRepo extends FileRepo { return ( $row && $row->rd_namespace == NS_FILE ) ? Title::makeTitle( $row->rd_namespace, $row->rd_title )->getDBkey() : ''; // negative cache - } + }, + [ 'pcTTL' => $expiry ] ); // @note: also checks " " for b/c diff --git a/includes/libs/objectcache/WANObjectCache.php b/includes/libs/objectcache/WANObjectCache.php index e43d37b8ca..b212e9779d 100644 --- a/includes/libs/objectcache/WANObjectCache.php +++ b/includes/libs/objectcache/WANObjectCache.php @@ -918,6 +918,15 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { $this->lastRelayError = self::ERR_NONE; } + /** + * Clear the in-process caches; useful for testing + * + * @since 1.27 + */ + public function clearProcessCache() { + $this->procCache->clear(); + } + /** * Do the actual async bus purge of a key * diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 4d0e39c1d2..a99b4b926b 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -247,6 +247,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { } DeferredUpdates::clearPendingUpdates(); + ObjectCache::getMainWANInstance()->clearProcessCache(); ob_start( 'MediaWikiTestCase::wfResetOutputBuffersBarrier' ); }